using UnityEngine;
using System.Collections;

public class Stone : MonoBehaviour {

    public float lifetime;

	// Use this for initialization
	void Start () {
        StartCoroutine(WaitForDelete(lifetime));
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnCollisionEnter(Collision col)
    {

        if (col.gameObject.layer == Const.LAYER_ENEMY)
        {
            Debug.Log("hit");
            col.transform.parent.gameObject.GetComponent<Enemy>().StoneEffect();            
        }

        StopAllCoroutines();
        Destroy(this.gameObject);
    }

    IEnumerator WaitForDelete(float time)
    {
        yield return new WaitForSeconds(time);

        Destroy(this.gameObject);
    }

}
